/**
 * 
 */

/**
 * @author Michael Fildestine ID:309161594
 *
 */
public class Snowflake {
	
	private BasicStar originalStar;
	
	public Snowflake(){
		this.originalStar = new BasicStar();
	}
	
	public void draw(){
		int height =   Painter.getFrameHeight()/2;
		int width = Painter.getFrameWidth()/2;
		int maxRadius = Math.min(height, width)/2;
		int radius = maxRadius/4;
		Pixel p = new Pixel(height, width);
		Painter.setColor("blue");
		originalStar.draw(p, radius);
		draw(p, radius, 1);
	}
	
	public void draw(Pixel p, int radius, int depth ){
			if(depth >= 0){
				
				double theta = 0;										//the angle theta we use to calculate the x,y value of the tips of the star.							
				double xCoord = 0;
				double yCoord = 0;
				int counter = 0;
								
				while(counter < 6){										//	we draw 6 stars with 60 degree at the tip to the previous star.
					xCoord = p.getX() + Math.cos(theta)*radius;
					yCoord = p.getY() + Math.sin(theta)*radius;
					
					Pixel pixel = new Pixel((int)xCoord,(int)yCoord);
					draw(pixel,radius/3, depth - 1 );
					originalStar.draw(p, radius);
					
				theta = theta + 2*(Math.PI/6);
				counter = counter + 1;
				}
				
			}else{
				originalStar.draw(p, radius);
			}
	}
	
}	


